﻿using System;

namespace InfiniTec.Threading
{
	[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
	public sealed class EventBasedAsyncResultAttribute: Attribute
	{
		public static bool IsEventBasedAsyncResult(object instance)
		{
			if (instance == null) throw new ArgumentNullException("instance");

			object[] attributes = instance.GetType().GetCustomAttributes(typeof (EventBasedAsyncResultAttribute), false);
			if (attributes == null || attributes.Length == 0) return false;

			return (attributes[0] is EventBasedAsyncResultAttribute);
		}
	}
}
